package io.renren.controller;

import io.renren.constant.AppConstant;
import io.renren.entity.RoadLiveEntity;
import io.renren.service.RoadLiveService;
import io.renren.vo.RespModel;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author rdawnx
 * @package_name io.renren.controller
 * @class_name RoadLiveController.java
 * @author_email rdawnxhi@163.com
 * @JDK_version 1.8
 * @create_on 2019/07/24 22:25
 */
@RestController
@RequestMapping("/roadlive/roadlive")
public class RoadLiveController {

    @Autowired
    private RoadLiveService roadLiveService;
    /**
     * APP端根据地区获取视频播放列表
     *
     * @param area
     * @return
     */
    @GetMapping(value = "/getRoadLiveList/{area}", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "获取路况直播列表", produces = MediaType.APPLICATION_JSON_VALUE)
//    @com.cxytiandi.encrypt.springboot.annotation.Decrypt
    @com.cxytiandi.encrypt.springboot.annotation.Encrypt
    public RespModel getRoadLiveList(@PathVariable String area) {
        if (StringUtils.isBlank(area)) {
            return new RespModel<>().getRespModelInstance(AppConstant.PARAM_IS_MISS, null, null);
        }
        Map<String, Object> map = new HashMap<>();
        map.put("area", area);
        map.put("enable", 1);
        List<RoadLiveEntity> queryList = roadLiveService.queryList(map);
        return new RespModel(AppConstant.STATU_SUCCESS.getName(), AppConstant.STATU_SUCCESS.getValue(), "", queryList);
    }
}
